package 工厂模式;

public class Main {
    public static void main(String[] args) {
        Operation operation = null;
        Factory factory = null;
        String  str = "*";
        //创建对应工厂
        switch (str){
            case "+":
                factory = new AdditonFactory();
                break;
            case "-":
                factory = new DivisionFactory();
                break;
            case "*":
                factory = new MultiplicationFactory();
                break;
            case "/":
                factory = new SubtractionFactory();
                break;
            default:
                factory = new AdditonFactory();
                break;
        }
        operation = factory.createOperation();
        operation.setNumberA(5);
        operation.setNumberB(78);
        System.out.println(operation.getResult());
    }
}
